//
//  statusCellBottomView.swift
//  NSinaWeibo
//
//  Created by LoliQueen on 16/2/20.
//  Copyright © 2016年 LoliQueen. All rights reserved.
//

import UIKit
import SnapKit

class statusCellBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor(white: 0.95, alpha: 1)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //转发按钮点击事件
    @objc private func responsClick(){
    
        let tempVC = TransmitViewController()
        ///每次跳转都需要 做一次隐藏，很麻烦，自定义一个navigationController
//        tempVC.hidesBottomBarWhenPushed = true
        navViewController()?.pushViewController(tempVC, animated: true)
    }
    
    func setupUI(){
    
        self.addSubview(retweetButton)
       self.addSubview(commentButton)
       self.addSubview(likeButton)
        
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left).offset(homeVCMargin)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        commentButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            
            //设置等宽
            make.width.equalTo(retweetButton.snp_width)
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            
            //设置等宽
            make.width.equalTo(commentButton.snp_width)
            //三等分的第一步
            make.right.equalTo(self.snp_right)

        }
        
        let pre1 = preView()
        let pre2 = preView()
        addSubview(pre1)
        addSubview(pre2)
        
        pre1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.width.equalTo(0.5)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
        }
        
        pre2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(0.5)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
        }
        
        
        //添加点击事件
        self.retweetButton.addTarget(self, action: "responsClick", forControlEvents: .TouchUpInside)
    }
    
    ///平分线
    func preView() -> UIView {
        let pre = UIView()
        pre.backgroundColor = UIColor.lightGrayColor()
        return pre
    }
    
   private lazy var retweetButton :UIButton = UIButton(backImageName: nil, title: "转发", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_retweet")
    
   private lazy var commentButton : UIButton = UIButton(backImageName: nil, title: "评论", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_comment")
    
   private lazy var likeButton : UIButton = UIButton(backImageName: nil, title: "赞", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_unlike")

}
